package com.example.template.service.comand;

import com.example.template.utils.ApplicationContextHolder;
import com.example.template.utils.Command;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 如何在非托管对象中注入 Spring IoC 的托管对象？
 */
public class AddStudentCommand implements Command {

    private final AddStudentCommandReceiver receiver;

    public AddStudentCommand() {
//      this.receiver = studentService;
        this.receiver = ApplicationContextHolder.getApplicationContext()
                .getBean(AddStudentCommandReceiver.class);
    }

    /**
     * 自定义异常
     */

    /** 自定义事件 **/


    @Override
    public void execute() {
//      studentService.action(this);
        receiver.action(this);
    }

}
